﻿using System.Collections.Generic;
using System.Web.Mvc;
using Business;
using Dto;

namespace YaoYunDong.Controllers
{
    public class ChannelController : ChannelBaseController
    {
        private readonly ActivityBusiness activityBusiness = new ActivityBusiness();

        public ActionResult Index(string channelCode)
        {
            if (string.IsNullOrEmpty(channelCode))
            {
                return View("~/Views/Home/Index.aspx");
            }
            var channelDto = SiteChannelDictionary[channelCode];
            ViewData["ChannelCode"] = channelCode;
            return View("~/Views/Channel/" + channelDto.ChannelTemplateId + "/Index.aspx", channelDto);
        }

        public ActionResult ActivityList(string channelCode, int? currentPageNo)
        {
            ViewData["ChannelCode"] = channelCode;
            var channelDto = SiteChannelDictionary[channelCode];
            int totalCount;
            var dtos = activityBusiness.GetGroupActivityListByChannelId(currentPageNo ?? 1, 0, channelDto.ChannelId, out totalCount);
            var page = new PagingDto(totalCount, currentPageNo ?? 1, 10, dtos ?? new List<GroupActivityDto>());
            return View("~/Views/Channel/" + channelDto.ChannelTemplateId + "/ActivityList.aspx", page);
        }

        public ActionResult Menu(string channelCode)
        {
            var channelDto = SiteChannelDictionary[channelCode];
            return View("~/Views/Channel/" + channelDto.ChannelTemplateId + "/Menu.ascx");
        }
    }
}